import { IPSControl } from '../ipscontrol';
import { IPSDBToolbarPortlet } from './ipsdbtoolbar-portlet';
import { PSDBSysPortletPartImpl } from './psdbsys-portlet-part-impl';

export class PSDBToolbarPortletPartImpl extends PSDBSysPortletPartImpl implements IPSDBToolbarPortlet {
  protected contentpscontrol: IPSControl | null = null;

  getContentPSControl(): IPSControl | null {
    if (this.contentpscontrol != null) return this.contentpscontrol;
    const value = this.M.getContentPSControl;
    if (value == null) {
      return null;
    }
    this.contentpscontrol = this.findPSControl(value);
    return this.contentpscontrol;
  }

  get contentPSControl(): IPSControl | null {
    return this.getContentPSControl();
  }

  getContentPSControlMust(): IPSControl {
    const value = this.getContentPSControl();
    if (value == null) {
      throw new Error('未指定内容部件');
    }
    return value;
  }

  get cls(): string {
    return 'PSDBToolbarPortletPartImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.dashboard.IPSDBToolbarPortlet') return true;
    return super.instanceof(cls);
  }
}
